<form method="post" action="<?php $_SERVER["PHP_SELF"]?>">
<center>
<br/><br/><br/><br/>
<table>
    <tr>
        <td colspan=3 align=center>          
          <?php 
		  include("Libraries/BusinessLogic/games.php");
		  include("Libraries/BusinessLogic/statheres.php");
		  if(isset($_POST["sort_field"]))
		   { 
				$sort_field=$_POST["sort_field"];
				$keyword=$_POST["keyword"];
				$result=search_game($keyword,$sort_field);
			
				if($result)
				 {
					//Analoga me to "status" tou pinaka emfanizei ta katallila apotelesmata
					switch ($result['status']) 
					 {
						case statheres::OLA_OK:
							include("gamelist.php");
							echo_result($result['value']);
							break;				
						case statheres::NO_QUERY:
							echo "<script type=\"text/javascript\">";
							echo "alert(\"Den ektelestike to query\")";
							echo "</script>"; 
							echo "<noscript> <center><h4><font color='red'>Den ektelestike to query</p></h4></font> </noscript>";
							break;
						case statheres::NOT_SORTED:
							echo "<script type=\"text/javascript\">";
							echo "alert(\"Results are not sorted!!!\")";
							echo "</script>"; 
							echo "<noscript> <center><h4><font color='red'>Results are not sorted</p></h4></font> </noscript>";
							break;
						case statheres::EMPTY_FIELD:
							echo "<script type=\"text/javascript\">";
							echo "alert(\"You have to write something!!!\")";
							echo "</script>";// }
							echo "<noscript> <center><h4><font color='red'>You have to write something</p></h4></font> </noscript>";
							break;
						case statheres::WRONG_TITLE:
							echo "<script type=\"text/javascript\">";
							echo "alert(\"There is no game with this title!!!\")";
							echo "</script>";  
							echo "<noscript> <center><h4><font color='red'>There is no game with this title</p></h4></font> </noscript>";
							break;
						case statheres::LARGE_FIELD:
							echo "<script type=\"text/javascript\">";
							echo "alert(\"The title is too long!!!\")";
							echo "</script>";  
							echo "<noscript> <center><h4><font color='red'>The title is too long</p></h4></font> </noscript>";
							break;
					 }
				 }
				else
				 {
					echo "<center><h4><font color='red'>Select sort field!!!</p></h4></font>";
				 }
		  }		  
		  ?>
        </td>
    </tr>
</table>
</form>
